package BLL.User;

import BIZ.UserBiz;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

@WebServlet(name = "ChangeUserMessage", value = "/ChangeUserMessage")
public class ChangeUserMessage extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public ChangeUserMessage() {
        super();
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        HttpSession session = request.getSession();

        //获取表单递送的用户需要修改的电话和邮箱
        String PhoneNumber = new String(request.getParameter("PhoneNumber").getBytes(StandardCharsets.UTF_8));
        String Email = new String(request.getParameter("Email").getBytes(StandardCharsets.UTF_8));

        //从session获取用户
        String UserName = (String) session.getAttribute("UserName");

        UserBiz userBiz = new UserBiz();
        boolean changephone = userBiz.ChangePhone(PhoneNumber, UserName);
        int changeEmail = userBiz.ChangeEmail(Email, UserName);


    }

    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

}
